/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pv1682010;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

/**
 *
 * @author xstefan5
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws SQLException, UserNotEnrolledException, UserException, StatisticsException {
        Database db = new Database();
        UserManager userManager = new UserManager();
        userManager.setDataSource(db);
        CourseManager courseManager = new CourseManager();
        courseManager.setDataSource(db);
        User maagic = new User(999999, "Maagic", false);
        User filipko = new User(256402, "Filipko Stefanak", true);
        userManager.addUser(maagic, "hes");
        userManager.addUser(filipko, "hes");

        Course cr = new Course("JAVA", "popis");
        courseManager.addCourse(cr);
        cr.addTeacher(filipko);

        List<Course> courses = courseManager.getAllCourses();
        Course course = courses.get(0);
        Event event = new Event(course, "prvni", new Date(), new Date());
        courseManager.addEvent(event);
        courseManager.enroll(course, maagic);
        courseManager.enroll(course, filipko);
        //courseManager.addAttendee(event, maagic);
        //courseManager.addAttendee(event, filipko);
        Statistics statistics = new Statistics();
        statistics.setDataSource(db);
        System.out.println(statistics.getAtLeastAttended(course, 1));
        
    }
}
